home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / man / cat.n / format.n < prev    next >
Text File  |  1995-07-25  |  13KB  |  265 lines

  1.  
  2.  
  3.  
  4.      ffffoooorrrrmmmmaaaatttt((((nnnn))))                    TTTTccccllll (((( ))))                    ffffoooorrrrmmmmaaaatttt((((nnnn))))
  5.  
  6.  
  7.  
  8.      _________________________________________________________________
  9.  
  10.      NNNNAAAAMMMMEEEE
  11.           format - Format a string in the style of sprintf
  12.  
  13.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  14.           ffffoooorrrrmmmmaaaatttt _f_o_r_m_a_t_S_t_r_i_n_g ?_a_r_g _a_r_g ...?
  15.      _________________________________________________________________
  16.  
  17.  
  18.      IIIINNNNTTTTRRRROOOODDDDUUUUCCCCTTTTIIIIOOOONNNN
  19.           This command generates a formatted string in the same way as
  20.           the  ANSI  C  sssspppprrrriiiinnnnttttffff  procedure  (it  uses  sssspppprrrriiiinnnnttttffff  in its
  21.           implementation).  _F_o_r_m_a_t_S_t_r_i_n_g indicates how to  format  the
  22.           result, using %%%% conversion specifiers as in sssspppprrrriiiinnnnttttffff, and the
  23.           additional  arguments,  if  any,  provide   values   to   be
  24.           substituted  into  the result.  The return value from ffffoooorrrrmmmmaaaatttt
  25.           is the formatted string.
  26.  
  27.  
  28.      DDDDEEEETTTTAAAAIIIILLLLSSSS OOOONNNN FFFFOOOORRRRMMMMAAAATTTTTTTTIIIINNNNGGGG
  29.           The command operates by scanning _f_o_r_m_a_t_S_t_r_i_n_g from  left  to
  30.           right.  Each character from the format string is appended to
  31.           the result string unless it  is  a  percent  sign.   If  the
  32.           character is a %%%% then it is not copied to the result string.
  33.           Instead,  the  characters  following  the  %%%%  character  are
  34.           treated as a conversion specifier.  The conversion specifier
  35.           controls the conversion of the  next  successive  _a_r_g  to  a
  36.           particular  format  and the result is appended to the result
  37.           string in place of the conversion specifier.  If  there  are
  38.           multiple  conversion  specifiers  in the format string, then
  39.           each one controls the conversion of one additional _a_r_g.  The
  40.           ffffoooorrrrmmmmaaaatttt  command  must be given enough _a_r_gs to meet the needs
  41.           of all of the conversion specifiers in _f_o_r_m_a_t_S_t_r_i_n_g.
  42.  
  43.           Each conversion specifier may contain up  to  six  different
  44.           parts: an XPG3 position specifier, a set of flags, a minimum  |
  45.           field  width,  a  precision,  a  length  modifier,   and   a
  46.           conversion  character.   Any  of these fields may be omitted
  47.           except for the conversion character.  The  fields  that  are
  48.           present   must   appear  in  the  order  given  above.   The
  49.           paragraphs below discuss each of these fields in turn.
  50.  
  51.           If the %%%% is followed by a decimal number  and  a  $$$$,  as  in  |
  52.           ``%%%%2222$$$$dddd'',  then  the  value to convert is not taken from the  |
  53.           next sequential argument.  Instead, it  is  taken  from  the  |
  54.           argument indicated by the number, where 1 corresponds to the  |
  55.           first _a_r_g.  If the conversion  specifier  requires  multiple  |
  56.           arguments  because  of  ****  characters  in the specifier then  |
  57.           successive arguments are used, starting  with  the  argument  |
  58.           given  by the number.  This follows the XPG3 conventions for  |
  59.           positional  specifiers.   If  there   are   any   positional  |
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 7/17/95)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      ffffoooorrrrmmmmaaaatttt((((nnnn))))                    TTTTccccllll (((( ))))                    ffffoooorrrrmmmmaaaatttt((((nnnn))))
  71.  
  72.  
  73.  
  74.           specifiers  in  _f_o_r_m_a_t_S_t_r_i_n_g then all of the specifiers must  |
  75.           be positional.
  76.  
  77.           The second portion of a conversion specifier may contain any
  78.           of the following flag characters, in any order:
  79.  
  80.           ----         Specifies that the converted  argument  should  be
  81.                     left-justified  in its field (numbers are normally
  82.                     right-justified with leading spaces if needed).
  83.  
  84.           ++++         Specifies that a number should always  be  printed
  85.                     with a sign, even if positive.
  86.  
  87.           _s_p_a_c_e     Specifies that a space  should  be  added  to  the
  88.                     beginning  of  the  number  if the first character
  89.                     isn't a sign.
  90.  
  91.           0000         Specifies that the number should be padded on  the
  92.                     left with zeroes instead of spaces.
  93.  
  94.           ####         Requests an alternate output form.  For  oooo  and  OOOO
  95.                     conversions  it guarantees that the first digit is
  96.                     always 0000.  For  xxxx  or  XXXX  conversions,  0000xxxx  or  0000XXXX
  97.                     (respectively)  will  be added to the beginning of
  98.                     the result unless it is zero.  For  all  floating-
  99.                     point   conversions   (eeee,  EEEE,  ffff,  gggg,  and  GGGG)  it
  100.                     guarantees that the result always  has  a  decimal
  101.                     point.   For gggg and GGGG conversions it specifies that
  102.                     trailing zeroes should not be removed.
  103.  
  104.           The third portion of a  conversion  specifier  is  a  number
  105.           giving  a  minimum  field  width for this conversion.  It is
  106.           typically used to make columns line up in tabular printouts.
  107.           If the converted argument contains fewer characters than the
  108.           minimum field width then it will be padded so that it is  as
  109.           wide as the minimum field width.  Padding normally occurs by
  110.           adding extra spaces on the left of the  converted  argument,
  111.           but  the  0000  and ---- flags may be used to specify padding with
  112.           zeroes  on  the  left  or  with   spaces   on   the   right,
  113.           respectively.   If the minimum field width is specified as ****
  114.           rather than a number, then the next argument to  the  ffffoooorrrrmmmmaaaatttt
  115.           command  determines  the  minimum  field width; it must be a
  116.           numeric string.
  117.  
  118.           The fourth portion of a conversion specifier is a precision,
  119.           which consists of a period followed by a number.  The number
  120.           is used in different ways for different conversions.  For eeee,
  121.           EEEE,  and  ffff  conversions it specifies the number of digits to
  122.           appear to the right of the  decimal  point.   For  gggg  and  GGGG
  123.           conversions  it  specifies  the  total  number  of digits to
  124.           appear, including those on both sides of the  decimal  point
  125.           (however, trailing zeroes after the decimal point will still
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 7/17/95)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      ffffoooorrrrmmmmaaaatttt((((nnnn))))                    TTTTccccllll (((( ))))                    ffffoooorrrrmmmmaaaatttt((((nnnn))))
  137.  
  138.  
  139.  
  140.           be omitted unless the  ####  flag  has  been  specified).   For
  141.           integer conversions, it specifies a mimimum number of digits
  142.           to print (leading zeroes will be added if necessary).  For ssss
  143.           conversions it specifies the maximum number of characters to
  144.           be printed; if the string  is  longer  than  this  then  the
  145.           trailing  characters  will  be dropped.  If the precision is
  146.           specified with **** rather than a number then the next argument
  147.           to the ffffoooorrrrmmmmaaaatttt command determines the precision; it must be a
  148.           numeric string.
  149.  
  150.           The fourth part  of  a  conversion  specifier  is  a  length
  151.           modifier,  which  must  be  hhhh or llll.  If it is hhhh it specifies
  152.           that the numeric value should be truncated to a 16-bit value
  153.           before  converting.   This  option  is rarely useful.  The llll
  154.           modifier is ignored.
  155.  
  156.           The last thing in a conversion specifier  is  an  alphabetic
  157.           character   that  determines  what  kind  of  conversion  to
  158.           perform.  The following conversion characters are  currently
  159.           supported:
  160.  
  161.           dddd         Convert integer to signed decimal string.
  162.  
  163.           uuuu         Convert integer to unsigned decimal string.
  164.  
  165.           iiii         Convert integer to  signed  decimal  string;   the
  166.                     integer may either be in decimal, in octal (with a
  167.                     leading 0000) or in hexadecimal (with a leading 0000xxxx).
  168.  
  169.           oooo         Convert integer to unsigned octal string.
  170.  
  171.           xxxx or XXXX    Convert integer to  unsigned  hexadecimal  string,
  172.                     using   digits   ``0123456789abcdef''  for  xxxx  and
  173.                     ``0123456789ABCDEF'' for XXXX).
  174.  
  175.           cccc         Convert  integer  to  the   8-bit   character   it
  176.                     represents.
  177.  
  178.           ssss         No conversion; just insert string.
  179.  
  180.           ffff         Convert floating-point number  to  signed  decimal
  181.                     string of the form _x_x._y_y_y, where the number of _y's
  182.                     is determined by the precision (default:  6).   If
  183.                     the  precision  is  0  then  no  decimal  point is
  184.                     output.
  185.  
  186.           eeee or eeee    Convert  floating-point   number   to   scientific
  187.                     notation  in  the form _x._y_y_yeeee++++_____z_z, where the number
  188.                     of _y's is determined by  the  precision  (default:
  189.                     6).   If  the precision is 0 then no decimal point
  190.                     is output.  If the  EEEE  form  is  used  then  EEEE  is
  191.                     printed instead of eeee.
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 7/17/95)
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      ffffoooorrrrmmmmaaaatttt((((nnnn))))                    TTTTccccllll (((( ))))                    ffffoooorrrrmmmmaaaatttt((((nnnn))))
  203.  
  204.  
  205.  
  206.           gggg or GGGG    If the exponent is less than -4 or greater than or
  207.                     equal  to  the  precision,  then convert floating-
  208.                     point number as for %%%%eeee or %%%%EEEE.   Otherwise  convert
  209.                     as for %%%%ffff.  Trailing zeroes and a trailing decimal
  210.                     point are omitted.
  211.  
  212.           %%%%         No conversion: just insert %%%%.
  213.  
  214.           For the numerical conversions the argument  being  converted
  215.           must be an integer or floating-point string; format converts
  216.           the argument to binary and then converts it back to a string
  217.           according to the conversion specifier.
  218.  
  219.  
  220.      DDDDIIIIFFFFFFFFEEEERRRREEEENNNNCCCCEEEESSSS FFFFRRRROOOOMMMM AAAANNNNSSSSIIII SSSSPPPPRRRRIIIINNNNTTTTFFFF
  221.           The behavior of the format command is the same as the ANSI C  |
  222.           sssspppprrrriiiinnnnttttffff procedure except for the following differences:       |
  223.  
  224.           [1]                                                                ||
  225.                %%%%pppp and %%%%nnnn specifiers are not currently supported.
  226.  
  227.           [2]  For %%%%cccc conversions  the  argument  must  be  a  decimal
  228.                string,   which   will   then   be   converted  to  the
  229.                corresponding character value.
  230.  
  231.           [3]  The llll modifier is ignored;  integer values  are  always  |
  232.                converted as if there were no modifier present and real  |
  233.                values are always converted as if the llll  modifier  were  |
  234.                present  (i.e.  type  ddddoooouuuubbbblllleeee  is  used for the internal  |
  235.                representation).  If the hhhh modifier is  specified  then  |
  236.                integer   values   are   truncated   to   sssshhhhoooorrrrtttt  before  |
  237.                conversion.
  238.  
  239.  
  240.      KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  241.           conversion specifier, format, sprintf, string, substitution
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.      Page 4                                          (printed 7/17/95)
  262.  
  263.  
  264.  
  265.